package jeons.admin.code.biz.impl;

import java.util.List;

import jeons.admin.code.biz.CodeBiz;
import jeons.admin.code.dto.CodeDTO;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class CodeBizImpl extends SqlMapClientDaoSupport implements CodeBiz{
	@Autowired SqlMapClientTemplate sqlMapClientTemplate;
	
	
	@Override
	public void codeTitleInSert(CodeDTO codeDTO) {
		CodeDTO dto = new CodeDTO();
		dto.setType("TITLE");
		for (int i = 0; i < codeDTO.getEng_cd_title().length; i++) {
			dto.setEng_cd_titlea(codeDTO.getEng_cd_title()[i]);
			dto.setKor_cd_titlea(codeDTO.getKor_cd_title()[i]);
			sqlMapClientTemplate.insert("Code.insertData",dto);
		}
		
	}

	@Override
	public void codeListInSert(CodeDTO codeDTO) {
		CodeDTO dto = new CodeDTO();
		dto.setType(codeDTO.getType());
		for (int i = 0; i < codeDTO.getKor_cd_list().length; i++) {
			dto.setKor_cd_lista(codeDTO.getKor_cd_list()[i]);
			dto.setNum_cd_lista(codeDTO.getNum_cd_list()[i]);
			System.out.println("aaaaaaaaaaaaaaaaaaaaaaa");
			System.out.println(dto.getKor_cd_lista());
			System.out.println(dto.getNum_cd_lista());
			System.out.println(dto.getType());
			sqlMapClientTemplate.insert("Code.insertCodeListData",dto);
		}
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<CodeDTO> getCodeTitleList(String type) {
		return sqlMapClientTemplate.queryForList("Code.getList",type);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<CodeDTO> getCodeSubList(String type) {
		return sqlMapClientTemplate.queryForList("Code.getCodeSubList",type);
	}
		

}
